package com.example.xm.presenter.home;

import com.example.xm.base.BasePresenter;
import com.example.xm.bean.HomeBean.HomeArticleBean;
import com.example.xm.bean.HomeBean.HomeBannderBean;
import com.example.xm.bean.HomeBean.HomeHotUserBean;
import com.example.xm.bean.HomeBean.HomePhotoBean;
import com.example.xm.bean.HomeBean.HomeRecommendBean;
import com.example.xm.bean.HomeBean.HomeRewardBean;
import com.example.xm.bean.HomeBean.HomeSquareBean;
import com.example.xm.bean.HomeBean.HomeTopicDiscussedBean;
import com.example.xm.bean.HomeBean.HomeVideoBean;
import com.example.xm.common.CommonSubScriBer;
import com.example.xm.interfaces.home.IHome;
import com.example.xm.model.HttpManager;
import com.example.xm.utiles.RxUtils;

public class RecommendPresenter extends BasePresenter<IHome.RecommendView> implements IHome.RecommendPersenter {
    @Override
    public void getBanner() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getBanner()
                .compose(RxUtils.<HomeBannderBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeBannderBean>(mView) {
                    @Override
                    public void onNext(HomeBannderBean homeBannderBean) {
                        mView.getBannerReturn(homeBannderBean);
                    }
                }));
    }

    @Override
    public void getTopicDiscussed() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getTopicDiscussed()
                .compose(RxUtils.<HomeTopicDiscussedBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeTopicDiscussedBean>(mView) {
                    @Override
                    public void onNext(HomeTopicDiscussedBean homeTopicDiscussedBean) {
                        mView.getTopicDiscussedReturn(homeTopicDiscussedBean);
                    }
                }));
    }

    @Override
    public void getRecommend() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getRecommend()
                .compose(RxUtils.<HomeRecommendBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeRecommendBean>(mView) {

                    @Override
                    public void onNext(HomeRecommendBean homeRecommendBean) {
                        mView.getRecommendReturn(homeRecommendBean);
                    }
                }));
    }

    @Override
    public void getHotUser() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getHotUser()
                .compose(RxUtils.<HomeHotUserBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeHotUserBean>(mView) {
                    @Override
                    public void onNext(HomeHotUserBean homeHotUserBean) {
                        mView.getHotUserReturn(homeHotUserBean);
                    }
                }));
    }

    @Override
    public void getSquare() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getSquare()
                .compose(RxUtils.<HomeSquareBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeSquareBean>(mView) {
                    @Override
                    public void onNext(HomeSquareBean homeSquareBean) {
                        mView.getSquareReturn(homeSquareBean);
                    }
                }));
    }

    @Override
    public void getVideo() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getVideo()
                .compose(RxUtils.<HomeVideoBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeVideoBean>(mView) {
                    @Override
                    public void onNext(HomeVideoBean homeVideoBean) {
                        mView.getVideoReturn(homeVideoBean);
                    }
                }));
    }

    @Override
    public void getPhoto() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getPhoto()
                .compose(RxUtils.<HomePhotoBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomePhotoBean>(mView) {
                    @Override
                    public void onNext(HomePhotoBean homePhotoBean) {
                        mView.getPhotoReturn(homePhotoBean);
                    }
                }));
    }

    @Override
    public void getHomeArticle() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getHomeArticle()
                .compose(RxUtils.<HomeArticleBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeArticleBean>(mView) {
                    @Override
                    public void onNext(HomeArticleBean homeArticleBean) {
                        mView.getHomeArticleReturn(homeArticleBean);
                    }
                }));
    }

    @Override
    public void getHomeReward() {
        addSubscribe(HttpManager
                .getInstance()
                .getTpApi()
                .getReward()
                .compose(RxUtils.<HomeRewardBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<HomeRewardBean>(mView) {
                    @Override
                    public void onNext(HomeRewardBean homeRewardBean) {
                        mView.getHomeRewardReturn(homeRewardBean);
                    }
                }));
    }

}
